package com.ruoyi.web.controller.books;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.books.domain.BooksOutspread;
import com.ruoyi.books.service.IBooksOutspreadService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 非遗文化延伸Controller
 *
 * @author ruoyi
 * @date 2024-04-02
 */
@Anonymous
@RestController
@RequestMapping("/books/outspread")
public class BooksOutspreadController extends BaseController
{
    @Autowired
    private IBooksOutspreadService booksOutspreadService;

    /**
     * 查询非遗文化延伸列表
     */
//    @PreAuthorize("@ss.hasPermi('books:outspread:list')")
    @GetMapping("/list")
    public TableDataInfo list(BooksOutspread booksOutspread)
    {
        startPage();
        List<BooksOutspread> list = booksOutspreadService.selectBooksOutspreadList(booksOutspread);
        return getDataTable(list);
    }

    /**
     * 导出非遗文化延伸列表
     */
//    @PreAuthorize("@ss.hasPermi('books:outspread:export')")
    @Log(title = "非遗文化延伸", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BooksOutspread booksOutspread)
    {
        List<BooksOutspread> list = booksOutspreadService.selectBooksOutspreadList(booksOutspread);
        ExcelUtil<BooksOutspread> util = new ExcelUtil<BooksOutspread>(BooksOutspread.class);
        util.exportExcel(response, list, "非遗文化延伸数据");
    }

    /**
     * 获取非遗文化延伸详细信息
     */
//    @PreAuthorize("@ss.hasPermi('books:outspread:query')")
    @GetMapping(value = "/{outspreadId}")
    public AjaxResult getInfo(@PathVariable("outspreadId") Long outspreadId)
    {
        return success(booksOutspreadService.selectBooksOutspreadByOutspreadId(outspreadId));
    }

    /**
     * 新增非遗文化延伸
     */
//    @PreAuthorize("@ss.hasPermi('books:outspread:add')")
    @Log(title = "非遗文化延伸", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BooksOutspread booksOutspread)
    {
        return toAjax(booksOutspreadService.insertBooksOutspread(booksOutspread));
    }

    /**
     * 修改非遗文化延伸
     */
//    @PreAuthorize("@ss.hasPermi('books:outspread:edit')")
    @Log(title = "非遗文化延伸", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BooksOutspread booksOutspread)
    {
        return toAjax(booksOutspreadService.updateBooksOutspread(booksOutspread));
    }

    /**
     * 删除非遗文化延伸
     */
//    @PreAuthorize("@ss.hasPermi('books:outspread:remove')")
    @Log(title = "非遗文化延伸", businessType = BusinessType.DELETE)
	@DeleteMapping("/{outspreadIds}")
    public AjaxResult remove(@PathVariable Long[] outspreadIds)
    {
        return toAjax(booksOutspreadService.deleteBooksOutspreadByOutspreadIds(outspreadIds));
    }
}
